<?php

namespace app\model\not_del;

use think\Model;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 部门
 */
class DepartmentModel extends Model
{
    protected $name = 'department';

    /**
     * 关联多个用户
     * @return HasMany
     */
    public function users(): HasMany
    {
        return $this->hasMany(UserModel::class,'department_id');
    }

    /**
     * 关联多个部门管理员
     * @return HasMany
     */
    public function departmentAdmins(): HasMany
    {
        return $this->hasMany(DepartmentAdminModel::class,'department_id');
    }

    /**
     * 关联学制模板
     * @return BelongsTo
     */
    public function departmentLevel(): BelongsTo
    {
        return $this->belongsTo(DepartmentLevelModel::class,'mode')->bind(['mode_name' => 'name','level_rules']);
    }

}